package backs.game;


import java.util.ArrayList;
import java.util.List;

public class GameTeam
{
    public String teamName;
    public int maxNum;
    public List<GamePlayer> playerList= new ArrayList<>();

    public GameTeam(String teamName,int maxNum)
    {
        this.teamName=teamName;
        this.maxNum=maxNum;
    }

    public boolean addToTeam(GamePlayer user)
    {
        if(user.team==null&&(playerList.size()<maxNum||maxNum<=0))
        {
            user.team=this;
            this.playerList.add(user);
            return true;
        }
        return false;
    }

    public boolean leaveTeam(GamePlayer user)
    {
        if(user.team==this)
        {
            user.team=null;
            this.playerList.remove(user);
            return true;
        }
        return false;
    }
}
